package com.pf.controller;

import com.pf.dto.AddAddressReq;
import com.pf.mapper.entity.Address;
import com.pf.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {

    @Autowired
    private AddressService addressService;

    @PostMapping("/add")
    public String addAddress(@RequestBody AddAddressReq req) {
        addressService.addAddress(req);
        return "success";
    }

    @GetMapping("/getAll")
    public List<Address> getAllAddress() {
        return addressService.getAllAddress();
    }

    @GetMapping("/getAddress")
    public Address getAddress(@RequestParam("addressName") String addressName){
        return addressService.getAddress(addressName);
    }
}
